#include"comm.h"

int main()
{
  //读文件
  if(mkfifo(FIFE_NAME,0644)<0)
  {
    perror("creat fail\n");
  }
  int fd=open(FIFE_NAME,O_RDONLY);
  //int f2=open("b.txt",O_WRONLY);
  if(fd<0)
  {
    perror("open fail\n");
  }
  char msg[128];
  while(1)
  {
    msg[0]=0;
    ssize_t s=read(fd,msg,sizeof(msg)-1);
    if(s>0)
    {
      msg[s]=0;
      //write(f2,msg,s);
      printf("client#:%s\n",msg);
    }
     else if(s==0)
    {
     // write(f2,msg,s);
      printf("Client quit\n");
      break;
    }
    else 
    {
      printf("read error\n");
      break;
    }
  }
  close(fd);
}

